package net.neptech.model.order;

import jakarta.persistence.*;

import lombok.Data;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.Comment;

import java.math.BigDecimal;
import java.util.Date;

@Data
@Comment("支付记录")
@Entity
@Table(name = "payment_record", schema = "med_order_db")
public class PaymentRecord {
    @Id
    @Comment("主键")
    @Column(name = "id", nullable = false)
    private Long id;


    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @Comment("订单ID → order_master.id")
    @JoinColumn(name = "order_id", nullable = false)
    private OrderMaster order;


    @Comment("1微信/2支付宝/3银行卡/9其他")
    @Column(name = "pay_channel", nullable = false)
    private Byte payChannel;



    @Comment("第三方交易号")
    @Column(name = "out_trade_no", nullable = false, length = 64)
    private String outTradeNo;


    @Comment("实付金额（元）")
    @Column(name = "amount", nullable = false, precision = 10, scale = 2)
    private BigDecimal amount;


    @Comment("0待支付/1成功/2失败")
    @ColumnDefault("0")
    @Column(name = "status", nullable = false)
    private Byte status;

    @Comment("支付时间（成功时）")
    @Column(name = "paid_at")
    private Date paidAt;


    @Comment("记录时间")
    @ColumnDefault("CURRENT_TIMESTAMP")
    @Column(name = "created_at", nullable = false)
    private Date createdAt;

}